package entity;

import enums.ResultCodeEnum;

public class ResultEntity {

    private int code;
    private String message;
    private Object data;

    public ResultEntity() {
    }

    public ResultEntity(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResultEntity successResult(Object data,ResultCodeEnum result) {
        return new ResultEntity(result.getCode(), result.getMsg(), data);
    }

    public static ResultEntity successResult(){
        return new ResultEntity(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null);
    }
    public static ResultEntity failedResult(ResultCodeEnum result) {
        return new ResultEntity(result.getCode(), result.getMsg(), null);
    }

    public static ResultEntity failedResult(){
        return new ResultEntity(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg(), null);
    }
}
